import dayjs from 'dayjs';
import { convertTopChannelCpdeToName, convertTaskStatusToText } from '@/utils';

export default {
  name: 'AdjustTable',
  props: {
    data: {
      type: Array,
      default: () => [],
    },
    total: {
      type: Number,
      default: 0,
    },
    pageNum: {
      type: Number,
      default: 1,
    },
    pageSize: {
      type: Number,
      default: 10,
    },
    loading: {
      type: Boolean,
      default: false,
    },
  },
  computed: {
    currentPage() {
      return this.pageNum;
    },
  },
  data() {
    return {};
  },
  methods: {
    formatTime(time) {
      return time ? dayjs(time).format('YYYY-MM-DD HH:mm:ss') : '';
    },
    formatTopChannel(code) {
      return convertTopChannelCpdeToName(code);
    },
    formatStatus(status) {
      return convertTaskStatusToText(status);
    },
    onTaskRecord(row) {
      this.$emit('taskRecord', row);
    },
    onCancelTask(row) {
      this.$emit('taskCancel', row);
    },
    onPageSizeChange(pageSize) {
      this.$emit('pageSizeChange', { pageSize });
    },
    onPageNumChange(pageNum) {
      this.$emit('pageNumChange', { pageNum });
    },
  },
};
